package com.hliu.core.model;


import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import java.util.Date;

/**
 * author: 6
 * date: 13-4-8
 */
@MappedSuperclass
public abstract class BaseModel extends IdEntity<Long> {
	private static final long serialVersionUID = 1L;
	protected Date createdAt;
	protected Date updatedAt;

	@Column(name = "created_at")
	public Date getCreatedAt() {
		return createdAt;
	}

	public void setCreatedAt(Date createdAt) {
		if (createdAt == null) {
			createdAt = new Date();
		}
		this.createdAt = createdAt;
	}

	@Column(name = "updated_at")
	public Date getUpdatedAt() {
		return updatedAt;
	}

	public void setUpdatedAt(Date updatedAt) {
		if (updatedAt == null) {
			updatedAt = new Date();
		}
		this.updatedAt = updatedAt;
	}
}
